package com.chaos.auth.config.userdetails.service;

import com.chaos.auth.config.userdetails.service.base.UserDetailsExtService;
import com.chaos.auth.config.userdetails.service.common.AdminCommonDetailsService;
import com.chaos.system.api.data.RbacUserData;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.stereotype.Component;


@Slf4j
@Component
public class AdminByPhoneDetailsService implements UserDetailsExtService {

    @Resource
    private AdminCommonDetailsService adminCommonDetailsService;


    @Override
    public UserDetails loadUserByPhone(String phone, Long tenantId) {
        RbacUserData rbacUser = adminCommonDetailsService.getRbacUserDtoByPhone(phone, tenantId);
        return adminCommonDetailsService.getAdminUserDetails(rbacUser);
    }

    @Override
    public UserDetails loadUserByPhone(String phone) {
        RbacUserData rbacUser = adminCommonDetailsService.getRbacUserDtoByPhone(phone);
        return adminCommonDetailsService.getAdminUserDetails(rbacUser);
    }

}
